﻿using System.Diagnostics.Contracts;

namespace SetVersionNumber {

	/// <summary>
	/// Defines an abstract method for updating a version number
	/// </summary>
	[ContractClass(typeof(VersionStrategyContracts))]
	public interface IVersionStrategy {

		/// <summary>
		/// The name of the strategy
		/// </summary>
		string Name { get; }


		/// <summary>
		/// The human readable name of this strategy
		/// </summary>
		string Description { get; }


		/// <summary>
		/// Get the next version number to use based on the current version number.
		/// </summary>
		/// <param name="currentVersionNumber">The current version number in the file</param>
		/// <returns>
		/// The next version number to use.
		/// </returns>
		string GetNextVersionNumber( string currentVersionNumber );

	}//interface


	/// <summary>
	/// Defines the code contracts for the version strategies
	/// </summary>
	[ContractClassFor(typeof(IVersionStrategy))]
	public abstract class VersionStrategyContracts : IVersionStrategy {

		/// <summary>
		/// Prevent any kind of instantiation of this class
		/// </summary>
		private VersionStrategyContracts( ) {
			// EMPTY
		}


		/// <summary>
		/// The name of the strategy
		/// </summary>
		public string Name {
			get {
				Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
				return "name";
			}//get
		}


		/// <summary>
		/// The human readable name of this strategy
		/// </summary>
		public string Description {
			get {
				Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
				return "description";
			}//get
		}


		/// <summary>
		/// Get the next version number to use based on the current version number.
		/// </summary>
		/// <param name="currentVersionNumber">The current version number in the file</param>
		/// <returns>
		/// The next version number to use.
		/// </returns>
		public string GetNextVersionNumber( string currentVersionNumber ) {
			Contract.Requires(!string.IsNullOrWhiteSpace(currentVersionNumber));
			Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
			return "unused";
		}

	}//contract class

}//namespace
